﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DAL;

namespace SL
{
    [ServiceContract(
        // Require bindings that supports sessions between endpoints 
        SessionMode = SessionMode.Required,
        CallbackContract = typeof(IRemoteServiceCallback))]
    public interface IRemoteService
    {
        # region booking

        [OperationContract]
        void SaveBooking(Booking booking);

        # endregion

        # region seat

        [OperationContract]
        IList<ScreenCast_Seat> GetScreenCastSeats(ScreenCast screenCast);
        
        [OperationContract]
        IList<ScreenCast_Seat> GetBestSeats(List<ScreenCast_Seat> screenSeatList, int neededSeats, ScreenCast_Seat clickedSeat);
        
        [OperationContract]
        void ChangeSeatsAvailability(List<ScreenCast_Seat> screenSeats);
        
        [OperationContract]
        IList<Seat> GetSeats(MovieHall movieHall);

        # endregion

        # region cinema
        
        [OperationContract]
        IList<Cinema> GetCinemas();

        # endregion

        # region movie hall
        
        [OperationContract(Name = "GetMovieHallUsingId")]
        MovieHall GetMovieHall(int id);
        
        [OperationContract(Name = "GetMovieHallUsingScreenCast")]
        MovieHall GetMovieHall(ScreenCast screenCast);
        
        [OperationContract]
        IList<MovieHall> GetMovieHalls(Cinema cinema);

        # endregion

        # region movie
        
        [OperationContract(Name = "GetMoviesUsingCinema")]
        IList<Movie> GetMovies(Cinema cinema);
        
        [OperationContract]
        void AddMovie(Movie movie);
        
        [OperationContract]
        IList<Movie> SearchIMDBMovies(string title);

        # endregion

        # region screen cast
        
        [OperationContract]
        ScreenCast GetScreenCast(int id);
        
        [OperationContract]
        IList<ScreenCast> GetScreenCasts(Movie movie, Cinema cinema);
        
        [OperationContract]
        void AddScreenCast(ScreenCast screenCast);

        # endregion

        # region user
        
        [OperationContract]
        bool IsEmployeeAllowed(string initials);
        
        [OperationContract]
        User GetCustomer(string phoneNo);

        # endregion

        #region subscribe
        
        [OperationContract]
        bool Subscribe(ScreenCast screenCast);
        
        [OperationContract]
        bool Unsubscribe(ScreenCast screenCast);
        
        #endregion
    }

    // Callback contract
    public interface IRemoteServiceCallback
    {
        [OperationContract(IsOneWay = true)]
        void OnAction(List<ScreenCast_Seat> screenSeats);
    }
}
